package org.cybot.generator;

import java.util.ArrayList;
import java.util.List;

import org.cybot.entities.Bunch;
import org.cybot.entities.Cyclist;
import org.cybot.entities.Team;

public class BunchGenerator extends AbstractGenerator<Bunch> {

	@SuppressWarnings("unchecked")
	public Bunch generateInstance(Object... params) {
		Integer teamCount = (Integer) params[0];
		Integer cyclistCount = (Integer) params[1];

		CyclistGenerator cg = new CyclistGenerator();
		List<Cyclist> cyclists = new ArrayList<Cyclist>();
		for (int i = 0; i < cyclistCount; i++) {
			cyclists.add(cg.generateInstance((List<String>) params[2]));
		}

		List<Team> teams = new ArrayList<Team>();
		TeamGenerator teamGenerator = new TeamGenerator();
		for (int i = 0; i < teamCount; i++) {
			teams.add(teamGenerator.generateInstance(cyclists));
		}
		return new Bunch(teams);
	}

}
